import '../css/tips.css'
function Tips (data) {
  this.msg = data.msg
  this.type = data.type
  if (!this.elbox) {
    this.render()
  }
  return this
}
Tips.prototype.show = function () {
  this.elbox.style.top = '15px'
}
Tips.prototype.hide = function () {
  this.elbox.style.top = '-60px'
}
Tips.prototype.render = function () {
  let body = document.getElementsByTagName('body')[0]
  if (this.elbox) {
    this.elbox.setAttribute('type', this.type)
    this.elbox.innerHTML = this.msg
  } else {
    this.elbox = document.createElement('div')
    this.elbox.className = '__Tips'
    this.elbox.setAttribute('type', this.type)
    this.elbox.innerHTML = this.msg
    body.appendChild(this.elbox)
  }
}
export default Tips
